<template>
<Modal
	v-model="show"
	title="群发公告"
	:width="800"
	>
	<div>
		<Form :model="info" class="form_item" :label-width="150"  style="width: 100%;" :rules="ruleValidate">
			<Row>
				<Col>
					<FormItem label="发送对象：">
						<Select v-model="info.subject" placeholder="请选择主体" style="width: 200px;margin-right:10px;">
							<Option v-for="item in companyList" :value="item.id" :key="item.id">{{ item.name }}</Option>
						</Select>
						<Select v-model="info.subject" placeholder="请选择主体" style="width: 200px;margin-right:10px;">
							<Option v-for="item in companyList" :value="item.id" :key="item.id">{{ item.name }}</Option>
						</Select>
					</FormItem>
				</Col>
				<Col v-for="(item,id) in sendObjItem" :key="id">
					<FormItem label=" ">
						<Select v-model="info.subject" placeholder="请选择主体" style="width: 200px;margin-right:10px;">
							<Option v-for="item in companyList" :value="item.id" :key="item.id">{{ item.name }}</Option>
						</Select>
						<Select v-model="info.subject" placeholder="请选择主体" style="width: 200px;margin-right:10px;">
							<Option v-for="item in companyList" :value="item.id" :key="item.id">{{ item.name }}</Option>
						</Select>
					</FormItem>
				</Col>
				<Col>
					<div class="add_person">
						<div @click="handleSendObjItem" style="width:120px;"><img src="../../../assets/images/u8559.png" alt="">添加对象</div>
					</div>
				</Col>
			</Row>
			<Row>
				<Col>
					<FormItem label="公告内容：" prop="month">
						<textarea wrap="soft" spellcheck="false" placeholder="" rows="8" maxlength="500" class="ivu-input gongao_textarea"></textarea>
					</FormItem>
					<p class="content_p">内容上限不能超过<span>500</span>字，当前已输入<span>0</span>字</p>
				</Col>
			</Row>
			
		</Form>
	</div>
	<div slot="footer" style="text-align: center;">
		<Button type="primary" ghost size="large"  @click="einfo_cancel">取消</Button>&nbsp;&nbsp;&nbsp;&nbsp;
		<Button type="success" size="large"  @click="einfo_ok">确定</Button>
	</div>
</Modal>
</template>

<script>


export default {
  name: 'user_bar',
  data(){
	return {
		show:false,
		sendObjItem:[],
		info:{
			month:'',
			day:'',
			textareaVal:'',
			info:'',
			income:'',
			expenses:'',
			balance:'',
			region:'',
			team:'',
			subject:'',
			name:'',
		},
		ruleValidate:{
			month:[
				{ required: true, message: 'The name cannot be empty', trigger: 'blur' }
			]
		},
		companyList:[]
	};
  },
  props:['value','cinfo'],
  created(){
	this.show = this.value;
  },
  watch:{
	value(val){
		this.show = val;
	},
	show(val){
		this.$emit('input',val);
		if(!val){
			// 关闭模态框
			this.sendObjItem = []
		}
	}
  },
  methods: {
	handleSendObjItem() {
	  this.sendObjItem.push({id:1})
	},
	einfo_ok(){
	
		var self = this;
		var data =  [this.info];
		var postdata = {
			data:JSON.stringify(data),
			date_month:this.info.date_month,
			company_id:this.info.id
		};
		
		Whttp.load('Chuna/Cash/update',postdata,function(result){
			self.einfo.show = false;
			self.load_data();
			self.$Message.info('提交成功');
		});
		
	},
	einfo_cancel(){
		this.show = !this.show;
	},
  }
}
</script>
<style scoped>
.form_item .ivu-form-item{
    margin-bottom:  12px;
}
.add_person{
	font-size: 16px;
	color: #9c9b9a;
	padding-left: 150px;
	margin-bottom: 15px;
}
.add_person img{
	width: 32px;
	height: 32px;
	vertical-align: bottom;
    margin-right: 8px;
}
.content_p{
	padding-left: 150px;
}
.content_p span{
	color: red;
}
.gongao_textarea{
	width: 400px;
	resize:none ;
}
</style>